#include "graphmodel.h"
#define M_PI 3.14

GraphModel::GraphModel()
{
    adjMatrix  = 0;
    vertexCount= 0;
}

GraphModel::~GraphModel()
{
}

void GraphModel::SetGraphModel(int *matrix, int vertex)
{
    adjMatrix = matrix;
    vertexCount = vertex;
}

int GraphModel::getVertexCount() {
    return vertexCount;
}

int GraphModel::getMatrixEl(int i, int j) {
    return adjMatrix[i*vertexCount + j];
}

int GraphModel::getEdgeCount() {
    int res = 0;
    for (int i = 1; i < vertexCount; ++i)
        for (int j = i; j < vertexCount; ++j)
            if (adjMatrix[i*vertexCount + j])
                ++res;
    return res;
}

QPointF GraphModel::getVertexCoords(int vertexNo) {
    double R = 200;
    double x0 = R*cos(2*M_PI*vertexNo/vertexCount);
    double y0 = R*sin(2*M_PI*vertexNo/vertexCount);
    QPointF res(x0, y0);
    return res;
}
